package com.letme.store.domain.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.letme.common.core.domain.entity.MallClassification;
import io.swagger.annotations.ApiModel;
import lombok.Data;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @Description
 * @Author lock-xq
 * @Date 2024/12/17 15:51
 **/
@Data
@ApiModel(value = "产品分类返回回对象")
public class ClassificationVO {

    private Long classId;

    private String typeName;

    private String typeImg;

    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<ClassificationVO> children;

    public ClassificationVO() {

    }

    public ClassificationVO(MallClassification classification)
    {
        this.classId = classification.getClassId();
        this.typeName = classification.getTypeName();
        this.typeImg = classification.getTypeImg();
        this.children = classification.getChildren().stream().map(ClassificationVO::new).collect(Collectors.toList());
    }
}
